package com.holyant.goods.enums;

/**
 *  报价类型枚举
 */
public enum QuoteTypeEnum {
    GUIDE_PRICE(10, "指引价"),
    SETTLE_PRICE(20, "结算价"),
    PURCHASE_PRICE(30, "采购价"),
    SALES_PRICE(40, "销售价");

    private final Integer code;
    private final String name;

    QuoteTypeEnum(Integer code, String name)
    {
        this.code = code;
        this.name = name;
    }

    public Integer getCode()
    {
        return code;
    }

    public String getName()
    {
        return name;
    }

    public static String getNameByCode(Integer code) {
        for (QuoteTypeEnum item : QuoteTypeEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getName();
            }
        }
        return null;
    }

    public static Integer getCodeByName(String name) {
        for (QuoteTypeEnum item : QuoteTypeEnum.values()) {
            if (item.getName().equals(name)) {
                return item.code;
            }
        }
        return null;
    }

    public static QuoteTypeEnum parse(Integer code) {
        for (QuoteTypeEnum item : QuoteTypeEnum.values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        return null;
    }

    public static QuoteTypeEnum parseByName(String name) {
        for (QuoteTypeEnum item : QuoteTypeEnum.values()) {
            if (item.getName().equals(name)) {
                return item;
            }
        }
        return null;
    }
}
